package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import lombok.Data;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据id查询中间表
     *
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> selectBySetmealId(Long id);

    /**
     * 添加一张中间表
     */
    void add(List<SetmealDish> setmealDish);

    /**
     * 更新新的套餐对应的id
     *
     * @param setmealDishes
     */
    void update(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id删除中间表
     *
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{id}")
    void deleteBySetmealId(Long id);

    /**
     * 根据餐单id查询套餐id
     *
     * @param id
     * @return
     */

    @Select("select setmeal_id from setmeal_dish where dish_id=#{id}")
    List<Long> selectSetmealIdByDishId(Long id);



}
